package com.taotao.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.taotao.common.bean.EUDataGridResult;
import com.taotao.common.bean.TaotaoResult;
import com.taotao.pojo.TbItemParam;
import com.taotao.service.ItemParamService;

/**
 * 商品类目管理模板
 * @author zqx the monster
 *
 */

@Controller
@RequestMapping("/item/param")
public class ItemParamController {
	@Autowired 
	private ItemParamService itemParamService;
	
	
	/**
	 * 查询类目列表
	 * @path  /item/param/list
	 * @param page
	 * @param rows
	 */
	@RequestMapping("/list")
	@ResponseBody
	public EUDataGridResult getItemParamList(@RequestParam(defaultValue = "1") Integer page,@RequestParam(defaultValue = "25") Integer rows) {
		System.out.println("page is:" + page + " ,and rows is :" + rows);
		EUDataGridResult result = itemParamService.getItemParamList(page, rows);
		return result;
	}

	
	
	/**
	 * 根据类目id查询类目
	 * @param itemCatId
	 * @return
	 */
	@RequestMapping("/query/{itemCatId}")
	@ResponseBody
	public TaotaoResult getItemParamByCid(@PathVariable long itemCatId) {
		TaotaoResult result = itemParamService.getItemParamByCid(itemCatId);
		return result;
	}
	
	/**
	 * 保存参数模板，向item_item_param插入数据
	 */
	@RequestMapping("/save/{cid}")
	@ResponseBody
	public TaotaoResult insertItemParam(@PathVariable long cid,String paramData) {
		TbItemParam itemParam = new TbItemParam();		
		itemParam.setParamData(paramData);
		itemParam.setItemCatId(cid);
		TaotaoResult result = itemParamService.insertItemParam(itemParam);
		return result;
	}
	
	
}
